package edu.caece.langprocessor.syntax;

import edu.caece.langprocessor.lexical.tokens.LexicalToken;

public class Terminal extends GrammarItem {

	private LexicalToken lexicalToken;

	public Terminal (LexicalToken lexicalToken){
		this.lexicalToken= lexicalToken;
	}
	
	@Override
	public String getValue() {
		return lexicalToken.getLexema();
	}
	
	public LexicalToken getLexicalToken() {
		return lexicalToken;
	}

	@Override
	public boolean equals(Object obj) {
		boolean isEqual = false;
		
		if (obj instanceof Terminal){
			Terminal other = (Terminal) obj;
			isEqual = this.lexicalToken.getToken().equals(other.getLexicalToken().getToken());
		}
		return isEqual;
	}

	@Override
	public int hashCode() {
		return this.lexicalToken.hashCode();
	}
	
	@Override
	public String toString() {
		return this.lexicalToken.getLexema();
	}
}
